interface DistanceType {
  x: number;
  y: number;
  z: number;
}
type CenterPointType = number[];
interface MyMeasureResultProps {
  distance: DistanceType | null; // 如果没有选择足够的点，可能为null
  centerPoint: CenterPointType | null; // 如果没有选择足够的点，可能为null
  measureTab: string;
}
export const MyMeasureResult: React.FC<MyMeasureResultProps> = ({
  distance,
  centerPoint,
  measureTab,
}) => {
  function formatNumber(num) {
    return parseFloat(num.toFixed(4));
  }
  return (
    <>
      {measureTab === 'twoPts' && distance ? (
        <>
          <div>
            <span>dx:</span>
            <span>{formatNumber(distance.x)}</span>
          </div>
          <div>
            <span>dy:</span>
            <span>{formatNumber(distance.y)}</span>
          </div>
          <div>
            <span>dz:</span>
            <span>{formatNumber(distance.z)}</span>
          </div>
        </>
      ) : measureTab === 'threeCircle' && centerPoint ? (
        <>
          <div>
            <span>X:</span>
            <span>{formatNumber(centerPoint[0])}</span>
          </div>
          <div>
            <span>Y:</span>
            <span>{formatNumber(centerPoint[1])}</span>
          </div>
          <div>
            <span>Z:</span>
            <span>{formatNumber(centerPoint[2])}</span>
          </div>
        </>
      ) : null}
    </>
  );
};
